
class Student{
    //私有属性name
    private String name = "bit";
    //公有属性age
    public int age = 18;
    //不带参数的构造方法
    public Student(){
        System.out.println("Student()");
    }
    private Student(String name,int age) {
        this.name = name;
        this.age = age;
        System.out.println("Student(String,name)");
    }
    private void eat(){
        System.out.println("i am eat");
    }
    public void sleep(){
        System.out.println("i am pig");
    }
    private void function(String str) {
        System.out.println(str);
    }
    @Override
    public String toString() {
        return "Student{" +
                "name='" + name + '\'' +
                ", age=" + age +
                '}';
    }
}

public class Text2 {
    public static void main(String[] args) throws ClassNotFoundException {
        //一个类  只能拥有一个class对象
        // forName方法要声明异常或者try crash去处理异常 他是一个受查异常
        Class<?> c1 = Class.forName("Student");
        /*forname中要写类所在的路径，
        就是哪个包下的哪个类，
        但是现在在src这个包下面，直接写名字即可*/
        Class<?> c2 = Student.class;//类名.方法
        Student student = new Student();
        Class<?> c3 = student.getClass();//对象.getClass方法
        System.out.println(c1 == c2);
        System.out.println(c2 == c3);
        System.out.println(c1 == c3);
    }
}
